//
//  AssetsViewController.m
//  ZHIFUBAO
//
//  Created by 高新川 on 15/6/16.
//  Copyright (c) 2015年 高新川. All rights reserved.
//

#import "AssetsViewController.h"
#import "AssetsHeadView.h"

@interface AssetsViewController ()

@end

@implementation AssetsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.modal = [[AssetsModal alloc] init];
    self.title = @"财富";
    
    // 添加设置按钮
    UIBarButtonItem *setting = [[UIBarButtonItem alloc] initWithTitle:@"设置" style:UIBarButtonItemStylePlain target:self action:@selector(clickedSetting)];
    self.navigationItem.rightBarButtonItem = setting;
    
    AssetsHeadView *head = [[[NSBundle mainBundle] loadNibNamed:@"AssetsHeadView" owner:nil options:nil] lastObject];
    head.money.layer.borderWidth = 0.5;
    [head.money setTitle:@"余额               606.50" forState:UIControlStateNormal];
    head.banks.layer.borderWidth = 0.5;
    [head.banks setTitle:@"银行卡               2张" forState:UIControlStateNormal];
    self.tableView.tableHeaderView = head;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 几行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section <= 1) {
        return 3;
    }
    else {
        return 1;
    }
}

// 几个section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return @"   ";
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellWithIdentifier = @"AssetsCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellWithIdentifier];
    }
    AssetsrUnitl *unitl = [self.modal.datas objectAtIndex:(indexPath.section*3+indexPath.row)];
    cell.imageView.image = [UIImage imageNamed:unitl.image];
    cell.textLabel.text = unitl.title;
    cell.detailTextLabel.text = unitl.detail;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)clickedSetting {
    NSLog(@"设置");
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
